package com.recruit.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.recruit.common.dto.friLink.CreateOrUpdateFriLinkDTO;
import com.recruit.common.mapper.FriLinkMapper;
import com.recruit.common.model.FriLinkDO;
import com.recruit.common.service.FriLinkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  友情链接-服务实现类
 * </p>
 *
 * @author Eval
 * @since 2022-04-04
 */
@Service
public class FriLinkServiceImpl extends ServiceImpl<FriLinkMapper, FriLinkDO> implements FriLinkService {

    @Resource
    private FriLinkMapper friLinkMapper;

    @Override
    public boolean createFriLink(CreateOrUpdateFriLinkDTO validator) {
        FriLinkDO  friLinkDO = new FriLinkDO();
        friLinkDO.setTitle(validator.getTitle());
        friLinkDO.setUrl(validator.getUrl());
        return friLinkMapper.insert(friLinkDO) > 0;
    }

    @Override
    public boolean updateFriLink(FriLinkDO friLinkDO, CreateOrUpdateFriLinkDTO validator) {
        friLinkDO.setTitle(validator.getTitle());
        friLinkDO.setUrl(validator.getUrl());
        return friLinkMapper.updateById(friLinkDO) > 0;
    }

    @Override
    public boolean deleteById(Integer id) {
        return friLinkMapper.deleteById(id) > 0;
    }

    @Override
    public List<FriLinkDO> getAll() {
        return friLinkMapper.selectList(null);
    }

    @Override
    public List<FriLinkDO> show() {
        return friLinkMapper.show();
    }
}
